let loginModule = (function (){
    let $userName = $(".userName")
    let $userPass = $(".userPass")
    let $submit = $(".submit")


    function handle() {
        $submit.click(async function(){
            let account = $userName.val().trim(),
                password = $userPass.val().trim()
            //格式校验(非空+格式)
            if(account==="" || password ===""){
                alert("用户名和密码不能为空！")
                return;
            }
            //给密码进行md5加密
            password = md5(password)
            //发送POST请求，把获取的账号密码传递给服务器
            let result = await axios.post("/user/login",{
                account,
                password
            })

                //服务器返回的结果
            if(parseInt(result.code)===0){
                alert("登录成功,即将跳转首页")
                window.location.href = "index.html"
                return
            }
            alert("输入的账号密码不匹配,请您重新输入")

        });
    }


    return {
        init(){
            handle()
        }
    }
})()
loginModule.init()